#coding=utf-8
from django.db import models

# Create your models here.

'''
调查主题
'''
class subject(models.Model):
    label=models.CharField(max_length=100,verbose_name='主题')
    thetime=models.DateTimeField(auto_now_add=True,verbose_name='创建时间')
    maker=models.ForeignKey('users.users',verbose_name='制定者')
    valid=models.BooleanField(verbose_name='有效',default=True)
    def __unicode__(self):
        return u'%s'%self.label
    class Meta:
        verbose_name = "调查主题"
        verbose_name_plural = "调查主题"
   
'''
调查题目
'''
class heading(models.Model):
    title=models.CharField(max_length=100,verbose_name='题目')
    serial=models.IntegerField(verbose_name='序号')
    subject=models.ForeignKey('subject',verbose_name='主题')
    def __unicode__(self):
        return u'%s'%self.title
    class Meta:
        verbose_name = "调查题目"
        verbose_name_plural = "调查题目"
'''
题目答案
'''
class answer(models.Model):
    title=models.CharField(max_length=100,verbose_name='答案')
    serial=models.IntegerField(verbose_name='序号')
    score=models.FloatField(verbose_name='分值')
    heading=models.ForeignKey('heading',verbose_name='题目') 
    def __unicode__(self):
        return u'%s'%self.title
    class Meta:
        verbose_name = "答案选项"
        verbose_name_plural = "答案选项"
'''
调查结果
'''
class result(models.Model):
    customer=models.ForeignKey('customer.info',verbose_name='客户')
    heading=models.ForeignKey('heading',verbose_name='题目')
    answer=models.ForeignKey('answer',verbose_name='答案')
    thetime=models.DateTimeField(auto_now_add=True,verbose_name='时间')
    user=models.ForeignKey('users.users',verbose_name='业务员')
    def __unicode__(self):
        return u'%s-%s'%(self.heading,self.answer)
    class Meta:
        verbose_name = "调查结果"
        verbose_name_plural = "调查结果"